import { team } from '@src/db/src/models/battle/team'

/**
 * 判断用户是否在team表的任何队伍中
 * @param uid 用户uid
 * @returns Promise<boolean>
 */
export async function ifUidInTeam(uid: number | string): Promise<boolean> {
  // 查询所有队伍，查找成员字段中是否包含该uid
  const teams = await team.findAllValues({})
  for (const team of teams) {
    if (Array.isArray(team.members) && team.members.includes(String(uid))) {
      return true
    }
  }
  return false
}
